/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package simpledraw;

import java.awt.Graphics;
import java.awt.Point;
import java.awt.Polygon;
import java.util.Iterator;

/**
 *
 * @author renatocardoso
 */
public class TriangleShape extends Shapes
{

    @Override
  public void draw(Graphics g)
  {
    Point point = null;
    Iterator it = getList().iterator();
    //if the list does not contain the required two points, return.
    if(getList().size()<3)
    {
      return;
    }
    Polygon p = new Polygon();
    for(int i = 0; i < 3; i++)
    {
      point = (Point)it.next();
      p.addPoint((int)point.getX(), (int)point.getY());
    }

    g.drawPolygon(p);
    //getList().clear();
  }//end of draw for Triangle

}//Triangle
